import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'seriesProductsM',
  state: {},
  effects: {
    // 获取系列产品列表
    *getSeriesProducts({ payload, callback }, { call, put, select }) {
      const res = yield call(api.getSeriesProducts, {});
      // const res = {
      //     code: 0,
      //     msg: '',
      //     data: [
      //         {value:'1',title:'系列产品1',tag:0},
      //         {value:'2',title:'系列产品2',tag:1},
      //         {value:'3',title:'系列产品3',tag:1},
      //         {value:'4',title:'系列产品4',tag:1},
      //         {value:'5',title:'系列产品5',tag:1},
      //     ]
      // }
      let resultData = [];

      if (res && res.code == 0) {
        resultData = res.data.dataSource;
      } else {
        message.error((res && res.msg) || '获取系列产品失败!');
      }
      callback(resultData);
    },
  },

  reducers: {
    setState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
